package common;


import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;

public class MessageCallback implements OperationCallback
{
	private FacesContext ctx;

	public MessageCallback(FacesContext ctx)
	{
		this.ctx = ctx;
	}

	public void onSuccess(String msg)
	{
		ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Success!", msg));
	}

	public void onError(Throwable t)
	{
		ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error: ", t.getMessage()));
	}

	public void onError(String msg)
	{
		ctx.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error: ", msg));
	}

}
